#include <stdio.h>
#define N 4
#define M 3
int array[N] = { 1, 2, 3, 4 };

void partPermutation(int *a, int n, int m)
{

	if (m == 0) {
		//printf("%d\n",*a);
		// 打印整个排好序的数组
		for (int i = 0; i < M; i++)
			printf("%d\t", array[i]);
		printf("\n");
	}

	else {
		for (int i = 0; i < n; i++) {
			int tmp = a[0];
			a[0] = a[i];
			a[i] = tmp;
			//printf("%d\t",*a);
			partPermutation(a + 1, n - 1, m - 1);
			tmp = a[0];
			a[0] = a[i];
			a[i] = tmp;
		}
	}

}

int main(void)
{
	//int array[3] = {1,2,3};
	//int m=1;
	partPermutation(array, N, M);
	return 0;
}
